# @Version        : 1.0
# @Update Time    : 2024/12/11 20:48
# @File           : operation_record_model.py
# @IDE            : PyCharm
# @Desc           : 操作记录表
from advanced_alchemy.base import BigIntAuditBase
from sqlalchemy import String, Integer, Numeric, Text
from sqlalchemy.orm import mapped_column, Mapped


class OperationRecord(BigIntAuditBase):
    __tablename__ = "sys_operation_record"
    __table_args__ = {"comment": "操作日志表"}
    username: Mapped[str | None] = mapped_column(String(100), comment="用户名")
    client_ip: Mapped[str | None] = mapped_column(String(100), comment="客户端IP")
    request_api: Mapped[str | None] = mapped_column(String(255), comment="请求API")
    method: Mapped[str | None] = mapped_column(String(10), comment="请求方式")
    api_path: Mapped[str | None] = mapped_column(String(255), comment="请求路径")
    status_code: Mapped[int | None] = mapped_column(Integer, comment="状态码")
    params: Mapped[str | None] = mapped_column(Text, comment="请求参数")
    cost_time: Mapped[float] = mapped_column(Numeric(10, 4), comment="耗时")
    summary: Mapped[str | None] = mapped_column(String(255), comment="操作类型")
    description: Mapped[str | None] = mapped_column(String(255), comment="操作描述")
    tags: Mapped[str | None] = mapped_column(String(255), comment="标签")
    system: Mapped[str | None] = mapped_column(String(255), comment="操作系统")
    browser: Mapped[str | None] = mapped_column(String(255), comment="浏览器")
    route_name: Mapped[str | None] = mapped_column(String(255), comment="路由名称")
    content_length: Mapped[int | None] = mapped_column(Integer, comment="响应长度")
    request_id: Mapped[str | None] = mapped_column(String(255), comment="请求ID")
